package com.smt.modules.app.controller;

import com.smt.common.utils.R;
import com.smt.modules.app.annotation.Login;
import com.smt.modules.app.annotation.LoginUser;
import com.smt.modules.bus.entity.MemberUserEntity;
import com.smt.modules.bus.service.ConsumptionService;
import com.smt.modules.bus.vo.ConsumptionFileVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author zhangyi
 * @date 2018/10/24 10:41
 */
@RestController
@RequestMapping("/app/consumption")
@Api(tags = {"AppConsumptionController"}, description = "消费积分下载，升级(客户端接口)")
public class AppConsumptionController {

    @Resource
    private ConsumptionService consumptionService;

    /**
     * 查询积分
     *
     * @param memberUserEntity
     * @return
     */
    @Login
    @GetMapping("/showIntegral")
    @ApiOperation(value = "查询积分", httpMethod = "GET")
    public R showIntegral(@LoginUser MemberUserEntity memberUserEntity) {

        return consumptionService.showIntegral(memberUserEntity);
    }

    /**
     * 升级
     *
     * @param memberUserEntity
     * @return
     */
    @Login
    @PostMapping("/upgrade")
    @ApiOperation(value = "升级", httpMethod = "POST")
    public R upgrade(@LoginUser MemberUserEntity memberUserEntity) {
       return  consumptionService.upgrade(memberUserEntity);
    }

    /**
     * 下载
     *
     * @param consumptionFileVo
     * @param memberUserEntity
     * @return
     */
    @Login
    @PostMapping("/downloadConsumption")
    @ApiOperation(value = "下载消费积分", httpMethod = "POST")
    public R downloadConsumption(@RequestBody ConsumptionFileVo consumptionFileVo,
                                 @LoginUser MemberUserEntity memberUserEntity) {

        return consumptionService.downloadConsumption(consumptionFileVo, memberUserEntity);
    }
}
